/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package crm.entity;

import java.util.ArrayList;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author abet
 */
@Entity
@Table (name="crm_client")
public class Client {
    @Id
    @Column(name="client_id", length=10, nullable=false, unique=true)
    private String cId;
    
    @Column(name="client_name", length=255, nullable=false,unique=true)
    private String cName;
    
    @Column(name="client_category", length=255, nullable=false)
    private String cCategory;
    
    @Column(name="client_address", length=255, nullable=false)
    private String cAddress;
    
    @Column(name="client_city", length=255, nullable=false)
    private String cCity;
         
    @OneToMany(mappedBy="client", cascade=CascadeType.ALL)
    private List<ContactPerson> daftarCP=new ArrayList<ContactPerson>();

    @OneToMany(mappedBy="client", cascade=CascadeType.ALL)
    private List<Project> daftarProject=new ArrayList<Project>();

    public void addCp(ContactPerson cp){
  
  	daftarCP.add(cp);
    	cp.setClient(this);
    }
    
    public void removeCp(ContactPerson cp){
    	daftarCP.remove(cp);
    	cp.setClient(null);
    }
       public String getcCategory() {
        return cCategory;
    }

    public void setcCategory(String cCategory) {
        this.cCategory = cCategory;
    }
    
    public void addProject(Project pj){
  
  	daftarProject.add(pj);
    	pj.setClient(this);
    }
    
    public void removeProject(Project pj){
    	daftarProject.remove(pj);
    	pj.setClient(null);
    }

        public List<Project> getDaftarProject() {
        return daftarProject;
    }

    public void setDaftarProject(List<Project> daftarProject) {
        this.daftarProject = daftarProject;
    }
     
    public List<ContactPerson> getDaftarCP() {
        return daftarCP;
    }

    public void setDaftarCP(List<ContactPerson> daftarCP) {
        this.daftarCP = daftarCP;
    }
    public String getcAddress() {
        return cAddress;
    }

    public void setcAddress(String cAddress) {
        this.cAddress = cAddress;
    }
    

    public String getcCity() {
        return cCity;
    }

    public void setcCity(String cCity) {
        this.cCity = cCity;
    }

    public String getcId() {
        return cId;
    }

    public void setcId(String cId) {
        this.cId = cId;
    }

    public String getcName() {
        return cName;
    }

    public void setcName(String cName) {
        this.cName = cName;
    }
}
